package com.yunji.product.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.product.dao.IProductTypeDao;
import com.yunji.product.domain.ProductTypeDO;
import com.yunji.product.mapper.ProductTypeMapper;
import com.yunji.product.params.ProductTypeParam;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductTypeDaoImpl extends BaseDaoImpl<ProductTypeMapper, ProductTypeDO> implements IProductTypeDao {
    @Override
    public List<ProductTypeDO> search(ProductTypeParam param) {
        return list(new LambdaQueryWrapper<ProductTypeDO>()
                .like(BeanUtils.isNotNull(param.getName()), ProductTypeDO::getName, param.getName())
                .orderByDesc(ProductTypeDO::getCreateTime));
    }
}
